<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    #box {
      border: 1px solid red;
      margin-left: 600px;
      border-radius: 50%;
    }
  </style>
  <body>
    <canvas id="box" width="200" height="200"></canvas>
  </body>
  <script>
    const box = document.querySelector("#box");
    const context = box.getContext("2d");
    context.translate(100, 100);
    context.beginPath();
    context.arc(0, 0, 100, (Math.PI / 180) * 0, (Math.PI / 180) * 360);
    context.stroke();
    //红
    context.beginPath();
    context.moveTo(0, 0);
    context.lineTo(200, 70);
    context.lineTo(-90, 120);
    context.lineTo(0, 0);
    context.fillStyle = "red";
    context.fill();
    context.stroke();
    //黄
    context.beginPath();
    context.moveTo(0, 0);
    context.lineTo(-130, -250);
    context.lineTo(-100, 130);
    context.lineTo(0, 0);
    context.fillStyle = "yellow";
    context.fill();
    context.stroke();
    //绿
    context.beginPath();
    context.moveTo(0, 0);
    context.lineTo(-100, -200);
    context.lineTo(330, 115);
    context.lineTo(0, 0);
    context.fillStyle = "green";
    context.fill();
    context.stroke();
  </script>
</html>
